<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <style type="text/css">
            .addBg {
                background: #f00;
                color: #fff;
            }
            .bigger {
                font-size:20px;
            }
        </style>
        <script type="text/javascript" src="jquery/jquery-1.11.3.js"></script>
        
        <script type="text/javascript">
            $(function(){
                $("#all").click(function(){
                    if($(this).prop("checked")) {
                        //all选中
                        $("input[type='checkbox']").prop("checked",true);
                        $(this).next("span").html("全取消");
                    }else {
                        $("input[type='checkbox']").prop("checked",false);
                        $(this).next("span").html("全选");
                    }
                });
                $("#reverse").click(function(){
                    //var c = $("input[type='checkbox']:not(#all):checked");
                    var c = $("input[type='checkbox'][id!='all']:checked");
                    var nc = $("input[type='checkbox'][id!='all']:not(:checked)");
                    c.prop("checked",false);
                    
                    nc.prop("checked",true);
                });
                
                
                
                
                
                
                
                
            });
        </script>
    </head>
    <body>
        <input type="checkbox"/><input type="checkbox"/><input type="checkbox"/><input type="checkbox"/>
        <input type="checkbox"/><input type="checkbox"/><input type="checkbox"/><input type="checkbox"/>
        <br/>
        <input type="checkbox" id="all"/><span>全选</span>
        <input type="button" id="reverse" value="反选"/>
    </body>
</html>
